package com.example.demo01.controller;

import com.example.demo01.entity.User;
import com.example.demo01.mapper.UserMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.List;

@Api(tags="user")
@RestController
@EnableSwagger2
public class UserController {
    @Autowired
    private UserMapper userMapper;
    @ApiOperation(value = "用户添加")
    @GetMapping("/addUser")
    public int AddUser(User user){
        System.out.println(user.getTimes());
        if (user!=null){
            if (user.getUid()!=0){

            }
        }
    return userMapper.insertUser(user);
    }
    @ApiOperation(value = "用户查询")
    @GetMapping("/getAll")
    public List<User> getAll(String names){
        return userMapper.getAll(names);
    }
    @ApiOperation(value = "删除操作")
    @GetMapping("/delete")
    public int delete(int uid){
        return userMapper.delete(uid);
    }
    @ApiOperation(value = "更新操作")
    @GetMapping("/update")
    public int update(int uid,String names){
        return userMapper.update(uid,names);
    }
}
